import Vue from 'vue'
import VueRouter from 'vue-router'
// import Home from '../views/Home.vue'

Vue.use(VueRouter)

const routes = [
  {
    path: '*',
    component: () => import('../views/404page/404page.vue')
  },
  {
    path: '/',
    component: () => import('../layout/index.vue'),
    redirect: '/home',
    children: [
      {
        path: '/home',
        component: () => import('../views/home/home.vue'),
        meta: {
          title: '首页',
          active: 0
        }
      },
      {
        path: '/home/newslist',
        component: () => import('../views/home/news/newslist.vue'),
        meta: {
          title: '新闻列表'
        }
      },
      {
        path: '/home/newsinfo/:id',
        component: () => import('../views/home/news/newsinfo.vue'),
        props: true, // 传递id
        meta: {
          title: '新闻详情'
        }
      },
      {
        path: '/friends',
        component: () => import('../views/friends/friends.vue'),
        meta: {
          title: '我的',
          active: 1
        }
      },
      {
        path: '/cart',
        component: () => import('../views/cart/cart.vue'),
        meta: {
          title: '购物车',
          active: 2
        }
      },
      {
        path: '/search',
        component: () => import('../views/search/search.vue'),
        meta: {
          title: '搜索',
          active: 3
        }
      }
    ]
  }
]

const router = new VueRouter({
  routes
})

export default router
